package hellfire.platform.input;

import hellfire.platform.screens.AbstractGameScreen;
import hellfire.system.R;
import hellfire.system.graphics.GLColor;
import hellfire.system.graphics.GLDrawable;
import hellfire.system.graphics.GLImage;
import hellfire.system.graphics.GLRelVec2;
import hellfire.system.graphics.GLString;
import hellfire.system.graphics.GLVec2;
import android.util.Log;
import android.view.MotionEvent;


/**
 * A cool button - 1 image,
 * changes mask color when pressed,
 * has a string title on it.
 * @author Roma
 *
 */
public class GLCoolButton extends GLButton
{
	/*
	protected boolean down = false;
	private AbstractGameScreen screen;
	protected GLImage image;
	private Runnable event;
	private int pressed, notPressed;
	*/
	private GLString str; 
	
	public GLCoolButton(AbstractGameScreen screen, GLVec2 pos, GLVec2 dim, int img, String str, Runnable event)
	{
		super(screen, pos, dim, img, img, event);
		image.setMaskColor(GLColor.ORANGE);
		this.str = new GLString(R.drawable.basefont, str, new GLRelVec2(0,0), dim.y()*0.6f);
		repositionString();
	}
	
	
	private void repositionString()
	{
		str.setPos(super.getPos());
	}
	
	public void onTouchEvent(MotionEvent e, GLVec2 pos)
	{
		super.onTouchEvent(e, pos);
		if(down) image.setMaskColor(GLColor.WHITE);
		else image.setMaskColor(GLColor.ORANGE);
	}
	
	@Override
	public void draw(float[] matrix) 
	{
		super.draw(matrix);
		str.draw(matrix);
	}

	public void setPos(GLVec2 pos) 
	{
		super.setPos(pos);
		repositionString();
	}
}
